<?php

include_once("{$_SERVER['DOCUMENT_ROOT']}/header.php");
include_once(PHP_ROOT . "/class/db/bbs/BbsListManager.php");

//오버라이딩
class CList extends BbsListManager {

    function cate_list() {
        $list.="<select class='w_200 h_20' id='" . $this->layer_id . "_cate' onChange=\"bbs.cateChange(this);\"> <option value='0'>-----이동할 카테고리-----</option>";
        $sql = "select* from tb_board_division";
        $r = $this->get_result($sql);
        while ($result = $r->fetch_assoc()) {
            $list.= "<option value='{$result['board_table']}'>{$result['board_description']}</option>";
        }
        $list.="</select>";
        return $list;
    }

    function set_style() {
        global $SESSION_ALL_EXCUTE;

        $_F = new Func();
        $token = $_F->makeToken($SESSION_ALL_EXCUTE);
        global $FOLDER_PATH;
        global $BBS_PATH;
        global $PAGE_ALL_DEL_OK;
        global $PAGE_ALL_MOVE_OK;
        global $PAGE_LIST;
        global $FOLDER_PATH_PHP;
        global $PAGE_MOD;
        $odd = 1;
        $cate_list = $this->cate_list();
        $admin = "
                    <tr >
                         <td class='left w_50' bgcolor='#ffffff'>
                        <input  type='checkbox' class='all_check_box' onClick=\"bbs.all_check_box('$this->layer_id',this);\"> *
                        </td>
                        <td colspan='100' bgcolor='#ffffff' style=\"text-align:left; \">
                            <input type='button' class='h_20' value='삭제' onClick=\"bbs.allExcute('$PAGE_ALL_DEL_OK','$this->layer_id','$token');\">
                            <input type='button'  class='h_20' value='이동' onClick=\"bbs.allExcuteMove('$PAGE_ALL_MOVE_OK',$('#" . $this->layer_id . "_cate').val(),'$this->layer_id','$token');\">
                            $cate_list
                            <select class='h_20'  id='listCount' title='보여질 리스트숫자' onChange=\"var l = $(this).val();bbs.swapPage('$PAGE_LIST&num='+l,'$this->layer_id');\" > 
                            <option value='10'>10줄</option>
                            <option value='15'>15줄</option>
                            <option value='20'>20줄</option>
                            <option value='30'>30줄</option>
                            <option value='50'>50줄</option>
                            <option value='100'>100줄</option>
                            <option value='1000'>1000줄</option>
                            <option value='10000'>10000줄</option>
                            </selcet>
                         </td>
                    </tr>";
        if ($this->getAdmin() == true) {
            echo"$admin";
        }
        while ($result = $this->result->fetch_object()) {


            $date = $_F->getDateFormat($result->reg_date, 1);
            if ($result->ban_expired_date) {
                $date2 = $_F->getDateFormat($result->ban_expired_date, 1);
            } else {
                $data2 = "";
            }



            $user_img = "<div><img src='/noritu/img/level_{$result->user_level}.png'></div>";
            $name = "<div  class='hand b'  onClick=\"bbs.loadMenu('member_info','{$PAGE_MOD}&bbs_uid={$result->user_num}','400','auto');\">$result->user_nick</div>";

            //관리자모드일때 체크박스표시
            if ($this->getAdmin() == true) {
                $all_check_box = "<input type='checkbox'  value='$result->user_num'>";
            } else {
                $all_check_box = "";
            }
            //홀수짝수구분해서 색지정
            if ($odd % 2 == 0) {
                $line_color = "#E5E5E5";
            } else {
                $line_color = "";
            }





            //시간계산
            $now = date("Y-m-d H:i:s");
            $end = $result->reg_date;
            $time = strtotime($now) - strtotime($end);
            $mm = ceil($time / 60);
            $h = 0;
            $m = ceil($mm % 60);


            if ($time >= 3600) {
                $h = ceil($time / 3600);
            } else {
                $h = 0;
            }


            //24시간 안된글
            if ($h >= 24) {

                $new_list = "";
            } else {
                if ($h > 0) {
                    $htime = "$h 시간";
                } else {
                    $htime = "";
                }
                $date = "<span style='color:red'>$htime $m 분 </span>전";
                $new_list = "<img src='/noritu/img/new_icon2.png' align='absmiddle'>";
            }


            //오버라이딩 구역 시작
            echo("
					
                                          <tr bgcolor='$line_color'>
                                                <td class=' h_30 left w_3p c_$result->user_num' >$all_check_box</td>
                                                <td class=' left  w_5p' >$result->user_num</td>
                                                <td class=' left '  >$user_img $name</td>
                                                <td class=' center '  >$result->is_manager</td>
                                                <td class=' left '  >$result->user_id</td>
                                                <td class=' left '  >$result->banned</td>
                                                <td class=' center '  >$result->user_level</td>
                                                <td class=' center '  >$result->alert_notice</td>
                                                <td class=' center '  >$result->alert_board</td>
                                                <td class=' center '  >$result->alert_comment</td>
                                                <td class=' left '  >$result->ip_addr</td>
                                                <td class=' left '  >$date</td>
                                           </tr>
					");
            //오버라이딩 구역 끝
            $depth = "";
            $odd++;
        }
    }

    function set_search() {

        global $db;
        global $FOLDER_PATH;
        global $BBS_PATH;
        global $PAGE_SEARCH;
        //오버라이딩 구역 시작
        $this->search = "
		<form id='searchForm_$this->layer_id'>
		<table class='bbs'>
		<tr>
		<td>
                <span class='select'>
		<select class='key_search_field' name='key_search_field'>
		<option value='user_num'>회원번호</option>
                <option value='user_id'>아이디</option>
                <option value='user_nick'>닉네임</option>
                <option value='user_email'>이메일</option>
                <option value='banned'>벤</option>
                <option value='user_level'>레벨</option>
                <option value='is_manager'>관리자</option>
                <option value='user_hash'>유저해쉬</option>
                <option value='ip_addr'>I P</option>
                <option value='activation_key'>액티베이션키</option>
                <option value='alert_notice'>경고</option>
                <option value='alert_board'>게시물경고</option>
                <option value='alert_comment'>코멘트경고</option>
		</select>
		</span>
		</td>
		<td>
                <input type='text' class='key_search' name='key_search' value='$this->key_search' class='bbs_input' onmouseover=\"bbs.getFocus(this);\"> 
		<input type='image' value='검색' src='$FOLDER_PATH/img/bt_search.gif' align='absmiddle' 
		onClick=\"bbs.search('searchForm_$this->layer_id','$PAGE_SEARCH&table=$this->table&page=$this->page&layer_id=$this->layer_id&category=$this->category&num=$this->end_no&order_by=$this->order_by','$this->layer_id','function(){}'); return false \" >
                </td>
		</tr>
		</table>
		</form>
                <script>
                if($('.key_search').val()!=''){
                $('.key_search_field').val('$this->key_search_field');
                    }
                    </script>
		";
        //오버라이딩 구역 끝
        echo "$this->search";
    }

    //총줄수 필요하면 오버라이딩
    function get_rows() {
        $row = $this->get_count($this->table, "where 1 $this->where", "user_num");
        return $row;
    }

    function show_list() {
        $sql = "select * from $this->table  where  1  $this->where order by $this->order_by desc limit $this->start_no,$this->end_no";
        $result = $this->get_result($sql);
        $this->result = $result;
        $this->set_style();
    }

}
